package com.feizhoutuobang.shapeline.web;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

@Controller
public class HomeController {

	private static Logger LOG = Logger.getLogger(HomeController.class);
	
	@Autowired
	FreeMarkerConfigurer freeMarkerConfigurer;
	
	@RequestMapping(value = "/index.shtml", method = RequestMethod.GET)
	public String index(Model model) {
		LOG.info("------------------------enter index--------------------");
		
		//Map map = new HashMap();
		//map.put("title", "<b>你好世界</b>");
		//geneHtmlFile("home.ftl", map, "e:\\home.html");
		
		model.addAttribute("title", "<b>&amp;hello world</b>");
		return "index";
	}
	
//	public void geneHtmlFile(String templateFileName, Map propMap, String htmlFileName ) {
//		Writer out = null;
//		try {
//			Template t = freeMarkerConfigurer.getConfiguration().getTemplate(templateFileName);
//			File afile = new File(htmlFileName);
//			out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(afile), "utf-8"));
//			t.process(propMap, out); 
//		}
//		catch (Exception e) {
//			LOG.error("", e);
//		}
//		finally {
//			try {out.close(); } catch (Exception e) {}
//		}
//	}
}
